import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

export default defineConfig({
  outputDir: "dist/esign",
  transpileDependencies: true,
  server: {
    host: "0.0.0.0",
    port: 8080,
    open: true, // vue项目启动时自动打开浏览器
    proxy: {
      "/ucop/customer/webapi/": {
        target:
          "http://ucop.dev.wuxi.epartical.com:18080/ucop/customer/webapi/",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/ucop\/customer\/webapi/, ""),
      },
    },
  },
  plugins: [vue()],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  build: {
    target: "es2020",
    cssTarget: "chrome80",
    outDir: "dist/esign",
  },
});
